import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import NotFoundComponent from '../views/NotFoundComponent.vue'

Vue.use(VueRouter)

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    redirect: 'Index',
    children: [
      {
        path: '/',
        name: 'Index',
        component: () => import('../views/Index.vue')
      },
      {
        path: '/xianyansuiyu',
        name: 'Xianyansuiyu',
        component: () => import('../views/Xianyansuiyu.vue')
      },
      {
        path: '/bokeriji',
        name: 'Bokeriji',
        component: () => import('../views/Bokeriji.vue')
      },
      {
        path: '/wodexiangce',
        name: 'Wodexiangce',
        component: () => import('../views/Wodexiangce.vue')
      },
      {
        path: '/guanyuwo',
        name: 'Guanyuwo',
        component: () => import('../views/Guanyuwo.vue')
      },
      {
        path: '/chengjieyewu',
        name: 'chengjieyewu',
        component: () => import('../views/Chengjieyewu.vue')
      },
      {
        path: '/liuyan',
        name: 'Liuyan',
        component: () => import('../views/Liuyan.vue')
      },
      {
        path: '/shijianzhou',
        name: 'Shijianzhou',
        component: () => import('../views/Shijianzhou.vue')
      },
      {
        path: '/gerenjianli',
        name: 'gerenjianli',
        component: () => import('../views/Gerenjianli.vue')
      },
      {
        path: '/chengjieyewu',
        name: 'Chengjieyewu',
        component: () => import('../views/Chengjieyewu.vue')
      },
      {
        path: '/yulubu',
        name: 'Yulubu',
        component: () => import('../views/Yulubu.vue')
      },
      {
        path: '/qianduan',
        name: 'Qianduan',
        component: () => import('../views/Qianduan.vue')
      }
    ]
  },
  { path: '*', component: NotFoundComponent }
]

const router = new VueRouter({
  mode: 'history',
  // history: createWebHistory('/go'),
  // base: process.env.BASE_URL,
  // base: '/go',
  routes,
  // scrollBehavior() {
  //   return {
  //     x: 0,
  //     y: 0
  //   }
  // }
})

export default router
